package com.example.springbootdemo.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author chenxiaomeng
 */
@Component
public class ApplicationContextAwareDemo implements ApplicationContextAware {
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //
//        Map<String, ApplicationContextAware> beansOfType = applicationContext.getBeansOfType(ApplicationContextAware.class);
//        List<ApplicationContextAware> values = new ArrayList<>(beansOfType.values());
//        for (int i = 0; i < values.size(); i++) {
//            System.out.println(values.get(i));
//        }

    }
}
